1. Field of the Invention
The present invention relates to a language processing unit and a language processing method to translate a source program and generate an object module file. More specifically, the present invention relates to a language processing unit and a language processing method that enable to generate an object module file with a shorter execution time in a range of code size designated by a programmer.
2. Description of the Related Art
A file that a language processing program translates an input source program and generates as its result is called an object module file.
In micro computers, especially in single chip micro computers, restrictions in their performance are apt to increase in number for the purpose of cost reduction. Therefore, in a language processing program, it is desired that the execution time of an object module file as a result of language processing (hereinafter simply referred to as "execution time") should be short, and the size of an object module file (hereinafter simply referred to as "code size") should be small.
However, in the conventional language processing units according to the prior art, an object module file has been output through optimization in which emphasis is put on either code size or execution time to an input source program.
As one of the above prior art, there has been a technology that was disclosed in, for example, the document "Microsoft C Optimizing Compiler User's Guide" (by Microsoft in 1988). In the document, described is a technology to generate an output code by selecting either an output with priority on the code size of an object module file or an output with priority on the execution time of an object module file by option at the execution of a language processing unit.
FIG. 10 shows a structure of a conventional language processing unit according to the prior art.
In FIG. 10, a language processing unit 82 analyzes an input source program file 81 by a syntax analyzing portion 83 thereof. After the completion of syntax analysis, control is transferred to a code generating portion 84, a command is selected on the basis of the analyzed results and the designation of a programmer, and thereby an output code is generated. After the completion of code generation, control is transferred to an object module file output portion 85, and an object module file 86 is output.
In the code generating portion 84, when the language processing unit 82 can generate plural output code patterns and can select any of the output code patterns, the selection of output code pattern is made by the choice of a programmer. Namely, when an output with priority on code size is designated, control is transferred to a code size priority code generating portion 841, and code generation is carried out so that a code size should be small.
In the code size priority code generating portion 841, priority is put on the reduction of code size rather than the improvement of execution time, the execution time of a generated object module file may become slow. On the other hand, when a programmer designates an output with priority on execution time, control is transferred to the execution time priority code generating portion 842, and code generation is made so that the execution time should become short. In the execution time priority code generating portion 842, priority is put on the improvement of execution time rather than the reduction of code size, therefore, the code size may increase.
In the next place, the algorithm of the conventional processing according to the prior art is explained in reference to FIG. 11 hereinafter.
In the conventional language processing method, first, the syntax analysis of a source program file that a programmer has input (step 901). Then, whether a programmer has designated the priority on code size, or whether he has designated the priority on execution time (step 902), and in the case of designation of the priority on code size, an output code is generated at a portion where plural output code patterns can be selected in code generation (Step 903). On the other hand, in the case of the priority on execution time, an output code is generated at a portion where plural code generations output code patterns can be selected in code generation (step 904). And after the completion of an output code, an object module file is output (Step 905).
However, in the conventional language processing technology described above, when a programmer wants both the reduction of code size and the improvement of execution time at one time to an object module file, it was difficult to output an object module file enough to meet the requirements of a programmer to both code size and execution time, which has been a problem with the conventional technology. This was because, in the above conventional technology, a programmer could only select whether the priority on the reduction of code size or the priority on the improvement of execution time, and in the designation of the priority on code size, execution time may become slow, while in the designation of the priority on execution time, code size may become large. Both the code size and the execution time depend on a operation code, however, there is not always the smallest and fastest command. Accordingly, when code size is made smallest, execution time may become slow, on the contrary, when execution time is made shortest, then code size may become large, which has been a problem with the conventional technology according to the prior art.